<?php 

class AdminControl extends CommonControl{
	/**
	 * [admin 用户列表]
	 * @return [type] [description]
	 */
	public function admin(){
		$admin=M('admin')->all();
		$this->assign('admin',$admin);
		if(isset($_GET['admin'])&&isset($_GET['aid'])){
		if($_GET['admin']=='lock')$data=M('admin')->where('aid='.$_GET['aid'])->update(array('`lock`'=>1));
		if($_GET['admin']=='unlock')$data=M('admin')->where('aid='.$_GET['aid'])->update(array('`lock`'=>0));
		if(isset($data))$this->back();

		}
		
		$this->display();
	}
	/**
	 * [add_admin 添加用户]
	 */
	public function add_admin(){
		if(IS_POST){
		if(isset($_POST['username'])&&isset($_POST['passwd1'])&&isset($_POST['passwd2'])){
			$data=M('admin')->where("username='{$_POST["username"]}'")->find();
			// var_dump($data);die;
			if($data)$this->error('用户名重复');
			if($_POST['passwd1']==$_POST['passwd2']){
				$data1=array(
					'username'=>$_POST['username'],
					'passwd'=>md5($_POST['passwd1'])	

					);
				$re=M('admin')->add($data1);
				if(isset($re))$this->error('添加成功');
			}else{
					$this->error('密码不一致');
				}
			}else{
				$this->error('请填写完整');
			}		
				
				
			
		
		}
		
		$this->display();
	}

}
 ?>